﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
using GMAC.ReportingSystem.Business.Entities;
using System.Data;
using Microsoft.Reporting.WebForms;

namespace GMAC.ReportingSystem.Paginas
{
    public partial class EfectividadPromesaPago : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //Se verifica que el usuario haya iniciado sesión
            if (!User.Identity.IsAuthenticated || Session["User"] == null)
            {
                System.Web.Security.FormsAuthentication.RedirectToLoginPage();
                return;
            }
            if (IsPostBack) return;
            Initialize();
            ValidateSecurity();

           
        }
        public void Initialize()
        {
            if (!this.IsPostBack)
            {
                //esto debe cargarse de las etiquetas ETIQUETA MORA TEMPRANA y ETIQUETA OVER
                this.ddlGroup.Items.Add(new ListItem("Vangent", "1"));
                this.ddlGroup.Items.Add(new ListItem("Over 60", "2"));
                this.ddlGroup.Items.Insert(0, new ListItem("All...", String.Empty));
                
                foreach (int i in Enum.GetValues(typeof(GeneralEnumTypes.Turn)))
                {
                    this.ddlTurn.Items.Add(new ListItem(Enum.GetName(typeof(GeneralEnumTypes.Turn), i).ToString().Replace('_', ' '), i.ToString()));

                }
                this.ddlTurn.Items.Insert(0, new ListItem("All...", String.Empty));
                

            }
        }
        private void ValidateSecurity()
        {
            //var beEntities = ((User)Session["User"]).Role.Security.GetEntitySecurity("User");
            //if (beEntities == null) return;
            //if (!beEntities.CanRead)
            //{
            //    grvUsers.Visible = false;
            //    btnModify.Visible = false;
            //    btnDelete.Visible = false;
            //    pnlSearch.Visible = false;
            //}
            //if (!beEntities.CanWrite)
            //{
            //    btnSave.Visible = false;
            //}
            //if (!beEntities.CanInsert)
            //{
            //    btnNew.Visible = false;
            //    btnCancel.Visible = false;
            //    pnlEdit.Visible = false;
            //}
            //if (!beEntities.CanDelete)
            //{
            //    btnDelete.Visible = false;
            //}
        }

        protected void imgBuscarReg_Click(object sender, ImageClickEventArgs e)
        {
            //List<ReportParameter> parametros = new List<ReportParameter>();
            //parametros.Add(new ReportParameter("Type", this.ddlType.SelectedValue));
            //parametros.Add(new ReportParameter("EstatusStr", this.ddlEstatus.SelectedItem.Text));
            //parametros.Add(new ReportParameter("Placa", this.txtPlaca.Text));
            //if (String.IsNullOrEmpty(this.ddlCliente.SelectedValue))
            //{
            //    parametros.Add(new ReportParameter("IdCliente", "0"));
            //}
            //else
            //{
            //    parametros.Add(new ReportParameter("IdCliente", this.ddlCliente.SelectedValue));
            //}
            //parametros.Add(new ReportParameter("Cliente", this.ddlCliente.SelectedItem.Text));
            //string FechaDesde = null;
            //if (string.IsNullOrEmpty(this.txtFechaDesde.Text))
            //{
            //    parametros.Add(new ReportParameter("FechaDesde", FechaDesde));
            //}
            //else
            //{
            //    parametros.Add(new ReportParameter("FechaDesde", this.txtFechaDesde.Text));
            //}
            //string FechaHasta = null;
            //if (string.IsNullOrEmpty(this.txtFechaHasta.Text))
            //{
            //    parametros.Add(new ReportParameter("FechaHasta", FechaHasta));
            //}
            //else
            //{
            //    parametros.Add(new ReportParameter("FechaHasta", this.txtFechaHasta.Text));
            //}

            //string asignacion = null;
            //if (!String.IsNullOrEmpty(this.txtAsignacion.Text.Trim()))
            //{
            //    asignacion = this.txtAsignacion.Text;
            //}
            //parametros.Add(new ReportParameter("Asignacion", asignacion));

            //string localizacion = null;
            //if (!String.IsNullOrEmpty(this.txtLocGeografica.Text.Trim()))
            //{
            //    localizacion = this.txtLocGeografica.Text;
            //}
            //parametros.Add(new ReportParameter("LocalizacionGeo", localizacion));


            //this.rptwReportes.Style.Add("margin-bottom", "26px");
            //this.rptwReportes.ServerReport.ReportPath = "/ReportSIT/rptServicios";
            //this.rptwReportes.ProcessingMode = ProcessingMode.Remote;
            //this.rptwReportes.ServerReport.ReportServerUrl = new Uri(ConfigurationManager.AppSettings["REPORT_SERVER"].ToString());
            //this.rptwReportes.ServerReport.SetParameters(parametros);
            Image1.Visible = true;
        }

        

        


    }
}
